# encoding=utf8

import time

'''
斐波那契数列：除1，2项外的第三项起，每一项的值都未前两项之和
example:1,1,2,3,5,8,13
'''
def fab1(maxsize):
	a,b,n = 0,1,0
	while n < maxsize:
		a,b = b,a+b
		n = n + 1


def fab2(maxsize):
	a,b,n = 0,1,0
	while n < maxsize:
		yield b
		a,b = b,a+b
		n = n + 1

if __name__ == '__main__':
	start_time = time.time()
	b = fab2(1000000)
	end_time = time.time()
	print('using time: %.2f' % (end_time-start_time) + 's')